package com.lc202310;

import java.util.HashMap;
import java.util.Map;

/**
 * Description:
 *
 * @Create 2023/10/15 20:18
 * @Version 1.0
 */
public class Solution137 {
    public int singleNumber(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            int tmp = map.getOrDefault(num, 0) + 1;
            if (tmp == 3) {
                map.remove(num);
                continue;
            }
            map.put(num, tmp);
        }
        return map.keySet().iterator().next();
    }
}
